package com.petadoption.serverclient.config;

import com.petadoption.serverclient.interceptor.JwtInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

import javax.annotation.Resource;

@Configuration
public class InterceptorConfig extends WebMvcConfigurationSupport {
    @Resource
    private JwtInterceptor jwtInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(jwtInterceptor)
//                .addPathPatterns("/**") //拦截的地址
                .excludePathPatterns("/**")
                .excludePathPatterns("/swipe")
                .excludePathPatterns("/plan")
                .excludePathPatterns("/pet/all")
                .excludePathPatterns("/pet/*")
                .excludePathPatterns("/deliver/*")
                .excludePathPatterns("/user/login")//不需要拦截登录接口
                .excludePathPatterns("/user/register");//注册接口
        super.addInterceptors(registry);
    }

//    @Bean
//    public JwtInterceptor jwtInterceptor() {
//        return new JwtInterceptor();
//    }

}
